INSERT INTO  TRASPARENZA

select 'T30',BOLLETTA,'','TOTALE ONERI DIVERSI SOGGETTI IVA','','','','','','','',SUM(TOTALE),'' FROM(
SELECT '',BOLLETTA,'','','','','','','','','',SUM(TOTALE) totale,'' FROM TRASPARENZA 
WHERE RIGA IN ('T27','T28','T29') AND ALI_IVA IS NOT NULL GROUP BY BOLLETTA
union
SELECT '',BOLLETTA,'','','','','','','','','',0 totale,'' FROM TRASPARENZA GROUP BY BOLLETTA)
group by bolletta

